﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CuaHangLaptop.DAL;

namespace CuaHangLaptop.BIZ
{
    public class ChiTietKho_BIZ
    {
        int id;
        string maChiTietKho;
        DateTime ngay;
        Laptop_BIZ laptop = new Laptop_BIZ();
        int tonkho;

        public int ID
        {
            get { return id; }
            set { id = value; }
        }

        public string MaCTKho
        {
            get { return maChiTietKho; }
            set { maChiTietKho = value; }
        }

        public DateTime Ngay
        {
            get { return ngay; }
            set { ngay = value; }
        }

        public Laptop_BIZ Laptop
        {
            get { return laptop; }
            set { laptop = value; }
        }

        public int Tonkho
        {
            get { return tonkho; }
            set { tonkho = value; }
        }

        public ChiTietKho_BIZ()
        {
        }

        public ChiTietKho_BIZ(int _id, string _ma, string _laptop, DateTime _ngay, int _tonkho)
        {
            id = _id;
            maChiTietKho = _ma;
            laptop = laptop.Get_Laptop_ByCode(_laptop);
            ngay = _ngay;
            tonkho = _tonkho;
        }

        public ChiTietKho_BIZ Get_CTKho_ByCode(string _MaCTKho)
        {
            return ChiTietKho_DAL.Get_CTKho_ByCode(_MaCTKho);
        }

        public List<ChiTietKho_BIZ> GetAll_CTKho()
        {
            return ChiTietKho_DAL.GetAll_CTK();
        }

        public int Get_TonKho_Now(string _malaptop)
        {
            return ChiTietKho_DAL.Get_TonKho_Now(laptop.MaLaptop);
        }

        public void Save()
        {
            if (id == -1) id = ChiTietKho_DAL.Insert(this);
            else ChiTietKho_DAL.Update(this);
        }

        public void Delete()
        {
            ChiTietKho_DAL.Delete(maChiTietKho);
        }

        public int Get_Lasted_ID()
        {
            return ChiTietKho_DAL.Get_Lasted_ID();
        }
    }
}
